<include file="Public/header.html"/>
</head>
<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
          <a><cite>首页</cite></a>
          <a><cite>提现管理</cite></a>
          <a><cite>提现列表</cite></a>
        </span>
       <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;height:30px;padding: 0 15px;"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <!--<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief" style="margin-left: 15px;">
	  	<ul class="layui-tab-title">
		    <li <?php if($flag == 'sq'){ ?> class="layui-this" <?php } ?> >
				<a href="{:U('Home/Web/Txrecord/txrecord_list',array('flag'=>'sq'))}">提现申请</a>
			</li>
			<li <?php if($flag == 'sz'){ ?> class="layui-this" <?php } ?> >
				<a href="{:U('Home/Web/Txrecord/txrecord_list',array('flag'=>'sz'))}">提现设置参数</a>
			</li>
	  	</ul>
  	</div>-->
    <div class="x-body">
    	<if condition="$flag eq 'sq' ">

	        <form class="layui-form x-center" action="{:U('Home/Web/Txrecord/txrecord_list')}"  method="post"  style="width:95%;margin-left: 5%;">
	            <div class="layui-form-pane" style="margin-top: 15px;">
	              	<div class="layui-form-item">             	                            
		                <div class="layui-input-inline">
		                  	<select name="status" id="status" lay-verify="required" lay-filter="type">
		                  		<option value="0">请选择状态</option>
							 	<option value="1" <?php if($status == 1){ echo 'selected'; } ?> >申请中</option>
							 	<option value="2" <?php if($status == 2){ echo 'selected'; } ?> >打款成功</option>
							</select>
		                </div>
		                <div class="layui-input-inline" style="width:80px">
		                    <button class="layui-btn" type="submit"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
		                </div>
	              	</div>
	            </div> 
	        </form>
	      	<form id="delform" class="layui-form">    	 	
	      	 	<table class="layui-table">     	 		
		            <thead>
		                <tr>
	                    	<th>ID</th>
	                    	<th>微信昵称</th>
	                    	<th>申请人</th>
	                    	<th>支付宝</th>
		                	<th>提现金额</th>
		                    <th>状态</th>
		                    <th>打款时间</th>
		                    <th>申请时间</th>
		                    <th>操作</th>
		                </tr>
		            </thead>
	          
		            <tbody id="formdata">
		              	<volist name="list" id="v">	
		                <tr>
	                    	<td>{$v.id}</td>
	                    	<td>{$v.nickname}</td>
	                    	<td>{$v.true_name}</td>
	                    	<td>{$v.zfb}</td>
							<td>{$v.cash}</td>
		                    <td>
		                    	<if condition="$v['status'] eq 1">
		                    		<font color="#0000FF">申请中</font>
		                    	<elseif condition="$v['status'] eq 2" />
		                    		<font color="#008000">打款成功</font>
		                    	</if>
		                    </td>
		                    <td><?php if(!empty($v['handle_time'])){ echo date('Y-m-d H:i:s', $v['handle_time']); } ?></td>
		                    <td><?php echo date('Y-m-d H:i:s', $v['add_time']); ?></td>                   
		                    <td class="td-manage"> 								
		                        <if condition="$v['status'] eq 1">
		                        	<a class="layui-btn layui-btn-xs layui-btn-normal"  href="javascript:;" onclick="cash_sh('{$v['id']}',2)">打款</a>
		                        </if>
		                    </td>
		                </tr>
		              	</volist>  
		            </tbody>
	            </table>
	            <span class="x-right" style="line-height:40px">共有数据：{$count} 条</span>
	      	</form>       
	        <div id="page"></div>
	        
        <elseif condition="$flag eq 'sz'" />
        	
        	<form class="layui-form">	    	
	        	<div class="layui-form-item"  >
	                <label  class="layui-form-label" style="width: 86px;">最低提现金额</label>
	                <div class="layui-input-block" style="margin-left: 116px;">
	                    <input type="text" id="mincash" name="mincash" lay-verify="required|num" autocomplete="off" value="{$list['mincash']}"  class="layui-input">
	                	<span><font color="red">单位（元）</font></span>
	                </div>
	            </div>
	            <div class="layui-form-item"  >
	                <label  class="layui-form-label" style="width: 86px;">最低手续费</label>
	                <div class="layui-input-block" style="margin-left: 116px;">
	                    <input type="text"  id="minsxf" name="minsxf"  lay-verify="required" autocomplete="off" value="{$list['minsxf']}"  class="layui-input">
	                	<span><font color="red">单位（元）</font></span>
	                </div>
	            </div>
			  	<div class="layui-form-item"  >
	                <label  class="layui-form-label" style="width: 86px;">提现手续费率</label>
	                <div class="layui-input-block" style="margin-left: 116px;">
	                    <input type="text"  name="sxf"  lay-verify="required" autocomplete="off" value="{$list['sxf']}"  class="layui-input">
	                	<span><font color="red">单位（%）</font></span>
	                </div>
	            </div>
	            <div class="layui-form-item" style="display: block;text-align: center;">
	           		<label for="L_sign" class="layui-form-label"></label>
	           		<button type="button" class="layui-btn" id="submitBtn" key="set-mine" lay-filter="save" lay-submit>立即提交</button>
	        	</div>
	        </form>
	        
    	</if>
    	
	</div>
    <include file="Public/footer.html"/>
    <script>    	
        layui.use(['form','element','laypage','layer'], function(){
          	var laypage = layui.laypage;//分页
          	var layer = layui.layer;//弹出层
          	var form = layui.form;
          	$ = layui.jquery; 
		  
		  	laypage.render({
			   	elem: 'page',
			   	count: '{$count}',
			   	limit: '{$limit}',
			   	curr : '{$page}', 
			   	jump: function(obj, first){
				   	if(!first){ 
				    	var $purl = "{:U('Home/Web/Txrecord/txrecord_list',array('page'=>'pageval','status'=>$status))}"
				    	window.location.href= $purl.replace('pageval',obj.curr);  			
				   	}
				}
		  	});

			form.verify({
				num: [/^[0-9]*[0-9][0-9]*$/,'只能输入整数'],
				max: [/^([0-9]\d?|100)$/,'只能输入0-100的整数']
			});
	    
		    form.on('submit(save)', function(data){              
				var tjing = parent.layer.msg('提交中...', {icon: 16,shade: 0.3,time: 60*1000}); 
		        var form = document.forms[0];
	  		    var formData = new FormData(form); 
	  		    
//	  		    var mincash = $("#mincash").val();
//	  		    var minsxf = $("#minsxf").val();
//	  		    if(mincash <= minsxf){
//	  		    	layer.msg('最低提现金额必须大于最低手续费', {icon: 2,offset: '40%',time:2000,shade: 0.3});
//	  		    	return false;
//	  		    }

				$.ajax({
			        url: "{:U('Home/Web/Txrecord/do_txsz')}",
			        type : "POST",
			        data :formData,
			        dataType:"text",
			        processData : false,         
			        contentType : false,      
			        success:function(data){
			        	console.log(data);
			            parent.layer.close(tjing);
		               	if(data == '1'){
		              	 	var index = parent.layer.getFrameIndex(window.name);
		                 	layer.msg('提交成功', {icon: 1,offset: '40%',time:2000,shade: 0.3},function(){ 
					        	location.reload();
						 	})
		               	}else if(data == '2'){
		              	 	layer.msg('提交失败', {icon: 2,offset: '40%',time:2000,shade: 0.3});
		               	}else{
		              	 	layer.msg(data, {icon: 2,offset: '40%',time:2000,shade: 0.3});
		               	}  
			        }
			    });	
            	return false;
          	});
        });  

		/*用户-查看*/
        function user_show(title,url,w,h){
            x_admin_show(title,url,w,h);
        }

        function cash_sh(id,status) {
            var par = {"id":id,'status':status};
			layer.confirm('确认要打款吗？',function(index){
				$.ajax({
					type: 'POST',
					url: "{:U('Home/Web/Txrecord/do_cash')}",
					data: par,
					dataType: 'text',
					success: function(data){
						if(data=='1'){
							layer.msg('提交成功！', {icon: 1,offset: '40%',time:1500,shade: 0.3},function(){
								location.reload();
							});   
						}else if(data=='2'){
							layer.msg('提交失败！', {icon: 2,offset: '40%',time:1500,shade: 0.3});
						}else{
							layer.msg(data, {icon: 2,offset: '40%',time:1500,shade: 0.3});
						}
					}
				});	
			});
        }

	</script>  
	</body>
</html>
